const { DataTypes } = require("sequelize");

const seq = require("../db/seq");

//! 创建模型 ( Model sh_topic --> sh_topics ) 默认会添加s
const Question = seq.define(
  "sh_question",
  {
    //? id字段自增，所以会被sequelize自动维护
    question_type: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: false,
      comment: "题目类型, math, english",
    },
    question_title: {
      type: DataTypes.STRING,
      allowNull: true,
      unique: false,
      comment: "题干的图片",
    },
    answer_a: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "答案A",
    },
    answer_b: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "答案B",
    },
    answer_c: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "答案C",
    },
    answer_d: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "答案D",
    },
    true_answer: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "正确答案",
    },
    answer_key: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "答案解析的图片",
    },
  },
  {
    tableName: "sh_questions", //todo 直接提供表名
    //timestamps: false, //?让seq不会自动创建createdAt 和 updatedAt
  }
);

//!强制同步数据库(创建数据表)
/* Question.sync({
  force: true, //? 将创建表, 如果表已经存在, 则将其首先删除
});
 */
module.exports = Question;
